package com.wanxi.set;

import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;

public class ScoreSort {
    public static void main(String[] args) {
        Set<StudentScore> set = new TreeSet<>(new Comparator<StudentScore>() {
            @Override
            public int compare(StudentScore o1, StudentScore o2) {
                int suma = o1.getChinese() + o1.getEnglish() + o1.getMath();
                int sumb = o2.getChinese() + o2.getEnglish() + o2.getMath();
                return -suma + sumb;
            }
        });
        set.add(new StudentScore("a", 22, 33, 24));
        set.add(new StudentScore("b", 23, 43, 4));
        set.add(new StudentScore("c", 232, 3, 34));
        set.add(new StudentScore("d", 212, 73, 14));
        System.out.println(set);
    }
}
